<template>
    <div class="top-nav">
      <div class="log">成人高考辅导班报名系统</div>
        <el-menu
        :default-active="activeIndex"
        mode="horizontal"
        @select="handleSelect">
        <el-menu-item index="1" >
          <template #title>课程中心</template>
        </el-menu-item>
        <el-menu-item index="2">
           <template #title>我的课程</template>
        </el-menu-item>

        <el-menu-item index="3">订单管理</el-menu-item>
        <el-menu-item index="4"><a href="https://www.ele.me" target="_blank">账户管理</a></el-menu-item>
      </el-menu>
      <div class="right-menu">
        <el-dropdown class="avatar-container" trigger="click">
          <div class="avatar-wrapper">
            <img src="http://localhost:8080/UserHead/1.jpg" class="user-avatar">
            <i class="el-icon-caret-bottom" />
          </div>
          <el-dropdown-menu slot="dropdown" class="user-dropdown">
            <router-link to="/">
              <el-dropdown-item class="right-menu-item">Home</el-dropdown-item>
            </router-link>
            <a href="https://github.com/PanJiaChen/vue-admin-template/" target="_blank">
              <el-dropdown-item class="right-menu-item">Github</el-dropdown-item>
            </a>
            <a href="https://panjiachen.github.io/vue-element-admin-site/#/" target="_blank">
              <el-dropdown-item class="right-menu-item">Docs</el-dropdown-item>
            </a>
            <el-dropdown-item divided @click.native="logout" class="right-menu-item">
              <span style="display:block;">Log Out</span>
            </el-dropdown-item>
          </el-dropdown-menu>
        </el-dropdown>
      </div>
    </div>
</template>

<script>
    export default {
       data:{
         return:{
           activeIndex: '1'
         }
       },
       methods:{
         handleSelect(key, keyPath) {
           console.log(key, keyPath);
           if(key === '1'){
             this.$router.push("/courseview");
           }
         }
       }
    }
</script>

<style scoped>
  .top-nav {
    width: 100%;
    background-color: #304156;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1001;
    overflow: hidden;
  }
  .log {
    padding: 0 20px;
    line-height: 56px;
    font-size: 24px;
    font-weight: bold;
    color: rgb(191, 203, 217);
    float: left;
  }
  .el-menu {
    float: left;
    border: none !important;
    background-color: #304156;
  }
  .nav-item {
    display: inline-block;
  }
  .right-menu {
    float: right;
    height: 100%;
  }
  .right-menu-item {
    display: inline-block;
    padding: 0 8px;
    height: 100%;
    font-size: 18px;
    color: #5a5e66;
    vertical-align: text-bottom;
  }
  .avatar-container {
    margin-right: 30px;
  }
  .avatar-wrapper {
    margin-top: 5px;
    position: relative;
  }
  .user-avatar {
    cursor: pointer;
    width: 40px;
    height: 40px;
    border-radius: 10px;
  }
  .el-icon-caret-bottom {
    cursor: pointer;
    position: absolute;
    right: -20px;
    top: 25px;
    font-size: 12px;
  }
</style>
